<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
#parse("page_include.html")
</head>
<body data-type="layout">
	<div data-defs="region:'north',border:false" style="height: 88px; padding: 2px"
		title="#springMessage('queryCondition')">
		<form id="queryForm" method="post">
			<table class="stable" cellpadding="1" cellspacing="1" style="width: 100%">
				<tr>
					<td width="15%" class="stdlabel">流程实例ID</td>
					<td width="15%" class="stdinput">
						<input data-type="inputbox" type="text" name="userName" data-defs="required:false"></input>
					</td>
					<td width="15%" class="stdlabel">当前登录人ID</td>
					<td width="15%" class="stdinput">
						<input data-type="inputbox" type="text" name="userName" data-defs="required:false"></input>
					</td>
					<td width="15%" class="stdlabel">当前登录人角色</td>
					<td width="15%" class="stdinput">
						<input data-type="inputbox" type="text" name="userName" data-defs="required:false"></input>
					</td>
				</tr>
				<tr>
					<td colspan="4"></td>
					<td colspan="2">
						<div style="margin: 0px 0; padding-top: 5px;" align="right">
							<a id="queryButton" href="javascript:void(0)" data-type="button" data-defs="iconCls:'icon-search'">查询</a>
							<a id="clearButton" href="javascript:void(0)" data-type="button" data-defs="iconCls:'icon-reload'">清空</a>
						</div>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<div data-defs="region:'center',border:false,fit:true" title="">
		<div data-type="layout" data-defs="fit:true" style="height: 500px;">
			<div data-defs="region:'west',split:true,title:'任务信息'" style="width: 350px; padding: 0px;">
				<table id="role_grid" data-type="grid" title="" style="height: 500px"
					data-defs="method:'post',
							url: '${rc.contextPath}/admin/queryRoleForAuthorityGrid.do',
							toolbar:'#orgTreeGridToolBar',idField:'roleId',
							rownumbers:true, pagination:false, fitColumns:true, fit:true">
					<thead>
						<tr>
							<th data-defs="field:'roleId',width:80,checkbox:true">ID</th>
							<th data-defs="field:'roleName',width:120">流程名称</th>
							<th data-defs="field:'roleDesc',width:120">任务名称</th>
						</tr>
					</thead>
				</table>
			</div>
			<div data-defs="region:'center',title:'任务详细'" style="width: 390px; padding: 0px;">
				<iframe src="${rc.contextPath}/demo/toActivieDiagramPage.do" width="100%" height="99.2%" style="overflow: hidden;"
					frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="yes"> </iframe>
			</div>
		</div>
	</div>
	<div id="usermanage_window" data-type="window" data-defs="modal:true,closed:true,iconCls:'icon-edit'"
		style="width: 600px; height: 300px; padding: 10px;">
		<form id="userForm" method="post">
			<table class="stable" cellpadding="1" cellspacing="1" style="width: 100%">
				<!-- 用户主键 -->
				<input type="hidden" name="userId"></input>
				<tr>
					<!-- 所在组织机构 -->
					<td width="25%" class="stdlabel">#springMessage("orgName")</td>
					<td width="75%" class="stdinput">
						<input data-type="combotree" type="text" name="orgId" style="width: 500px"
							data-defs="url: '${rc.contextPath}/admin/getOrgTree.do',
								method:'post',required:true"></input>
					</td>
				</tr>
				<tr>
					<!-- 用户名称 -->
					<td width="25%" class="stdlabel">#springMessage("userName")</td>
					<td width="75%" class="stdinput">
						<input data-type="inputbox" type="text" name="userName" style="width: 500px" data-defs="required:true"></input>
					</td>
				</tr>
				<tr>
					<!-- 登录名称 -->
					<td width="25%" class="stdlabel">#springMessage("loginName")</td>
					<td width="75%" class="stdinput">
						<input data-type="inputbox" type="text" name="loginName" style="width: 500px" data-defs="required:true"></input>
					</td>
				</tr>
				<tr>
					<!-- 用户性别 -->
					<td width="25%" class="stdlabel">#springMessage("userSex")</td>
					<td width="75%" class="stdinput">
						<input data-type="combobox" type="text" name="userSex" style="width: 500px"
							data-defs="editable:false,required:true,url:'${rc.contextPath}/getCombo.do?codeId=1'"></input>
					</td>
				</tr>
				<tr>
					<!-- 用户电话 -->
					<td width="25%" class="stdlabel">#springMessage("userPhone")</td>
					<td width="75%" class="stdinput">
						<input data-type="inputbox" type="text" name="userPhone" style="width: 500px" data-defs="required:true"></input>
					</td>
				</tr>
				<tr>
					<!-- 用户地址 -->
					<td width="25%" class="stdlabel">#springMessage("userAddress")</td>
					<td width="75%" class="stdinput">
						<input data-type="inputbox" type="text" name="userAddress" style="width: 500px"
							data-defs="required:false"></input>
					</td>
				</tr>
				<tr>
					<!-- 应用标志 -->
					<td width="25%" class="stdlabel">#springMessage("usedFlag")</td>
					<td width="75%" class="stdinput">
						<input id="usedFlag" data-type="combobox" type="text" name="usedFlag" style="width: 500px"
							data-defs="editable:false,required:true,url:'${rc.contextPath}/getCombo.do?codeId=3'"></input>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<div style="margin: 0px 0; padding-top: 5px;" align="center">
							<a href="#" onclick="clearFun()" data-type="button" data-defs="iconCls:'icon-clear'">
								#springMessage("buttonClear") </a>
							<a onclick="saveFun()" href="#" data-type="button" data-defs="iconCls:'icon-save'">
								#springMessage("buttonSave") </a>
							<a onclick="closeFun()" href="#" data-type="button" data-defs="iconCls:'icon-close'">
								#springMessage("buttonClose") </a>
						</div>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<script type="text/javascript">
        function clearFun() {
            $("#userForm").form('clear');
        }
        //保存人员基本信息
        function saveFun() {
            var url = "${rc.contextPath}/admin/saveUser.do";
            var v = $("#userForm").form('validate');
            if (!v) {
                return;
            }
            submitForm("userForm", url, function(rs) {
                var returnedObj = $.parseJSON(rs);
                showMsg(returnedObj.msgInfo);
                $("#userForm").form('load', { "userId" : returnedObj.data });
                $('#user_grid').grid("reload");
            });
        }
        function closeFun() {
            $("#usermanage_window").window("close");
        }
        //根据选择的人员信息获得人员的角色和资源信息
        function checkUserRoles(index, data) {
            $('#role_grid').grid("uncheckAll");
            var url = '${rc.contextPath}/admin/getUserRoles.do';
            var data = { "userId" : data.userId };
            ajaxPost(url, data, function(rs) {
                if (rs != null) {
                    for ( var i = 0; i < rs.length; i++) {
                        $('#role_grid').grid("selectRecord", rs[i].roleId);
                    }
                }
            });
        }
        $(document).ready(function() {
            $("#clearButton").bind("click", function() {
                $("#queryForm").form('clear');
            });
            $("#queryButton").bind("click", function() {
                var formValues = JSON.stringify($("#queryForm").form('getValues'));
                $('#user_grid').grid('load', { where : formValues });
            });
            $("#addButton").bind("click", function() {
                var options = { "windowId" : "usermanage_window", "title" : "#springMessage('userManageEdit')" };
                openWindow(options);
                $("#userForm").form('clear');
                $('#usedFlag').combobox('setValue', '1');
            });
            $("#editButton").bind("click", function() {
                var selectedRow = $('#user_grid').grid('getChecked');
                if (selectedRow == null || selectedRow.length == 0) {
                    showMsg('#springMessage("unSelectedMsg")');
                    return;
                }
                var options = { "windowId" : "usermanage_window", "title" : "#springMessage('userManageEdit')" };
                openWindow(options);
                $("#userForm").form('clear');
                var url = "${rc.contextPath}/admin/getUserDetail.do?userId=" + selectedRow[0].userId;
                $("#userForm").form('load', url);
            });
            $("#delButton").bind("click", function() {
                $("#userForm").form('clear');
                var selectedRow = $('#user_grid').grid('getChecked');
                if (selectedRow == null || selectedRow.length == 0) {
                    showMsg('#springMessage("unSelectedMsg")');
                    return;
                }
                confirmMsg('#springMessage("confirmDelete")', function(r) {
                    if (r) {
                        var url = '${rc.contextPath}/admin/deleteUser.do';
                        var data = { "userId" : selectedRow[0].userId };
                        ajaxPost(url, data, function(rs) {
                            showMsg(rs.msgInfo);
                            $('#user_grid').grid("reload");
                        });
                    }
                });
            });
            $("#saveButton").bind("click", function() {
                var url = '${rc.contextPath}/admin/saveUserRoles.do';
                var userRow = $('#user_grid').grid('getChecked');
                if (userRow == null || userRow.length == 0) {
                    showMsg('#springMessage("unSelectedMsg")');
                    return;
                }
                var roles = $('#role_grid').grid("getChecked");
                if (roles == null || roles.length == 0) {
                    roles = "";
                } else {
                    roles = JSON.stringify(roles);
                }
                var data = { "userId" : userRow[0].userId, "roles" : roles };
                ajaxPost(url, data, function(rs) {
                    showMsg(rs.msgInfo);
                });
            });
        });
    </script>
</body>
</html>